﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="TimKiem.aspx.cs"
    Inherits="WebRaoVat.TimKiem" Title="Tìm kiếm" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div id="box-pro-highlights">
        <div class="box-pro-highlights-header">
            <a href="###" target="_blank" class="no-hover">Tìm kiếm</a>
        </div>
        <div class="content" style="text-align: left">
            <div style="text-align: left">
                <p>
                    &nbsp;
                </p>
                <div style="text-align: left">
                    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
                    </asp:ToolkitScriptManager>
                    <asp:Panel ID="PanelTimKiemCoBan1" runat="server" Font-Size="Larger" ForeColor="Red">
                        <asp:Image ID="Image1" runat="server" />
                        Tìm kiếm cơ bản
                        <asp:Label ID="Label1" runat="server"></asp:Label>
                    </asp:Panel>
                    <div style="height: 5px">
                        &nbsp;
                    </div>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" Collapsed="false"
                                TargetControlID="PanelTimKiemCoBan2" CollapseControlID="PanelTimKiemCoBan1" CollapsedImage="images/Expand.png"
                                CollapsedText="(Mở ra)" ExpandControlID="PanelTimKiemCoBan1" ExpandedImage="images/collape.png"
                                ExpandedText="(Đóng lại)" ImageControlID="Image1" TextLabelID="Label1">
                            </asp:CollapsiblePanelExtender>
                            <asp:Panel ID="PanelTimKiemCoBan2" runat="server">
                                <table style="border: thin solid #0066cc; border-collapse: collapse; width: 100%;
                                    background-color: white" align="center">
                                    <tr>
                                        <td style="width: 58%; text-align: right">
                                            <asp:TextBox ID="txtSearch1" runat="server" Width="217px"></asp:TextBox>
                                        </td>
                                        <td style="width: 2%">
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:Button ID="btnSearch1" runat="server" Text="Tìm kiếm" OnClick="btnSearch1_Click" />
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                    <p>
                        &nbsp;
                    </p>
                    <asp:Panel ID="PanelTimKiemNangCao1" runat="server" Font-Size="Larger" ForeColor="Red">
                        <asp:Image ID="Image2" runat="server" />
                        Tìm kiếm nâng cao
                        <asp:Label ID="Label2" runat="server"></asp:Label>
                    </asp:Panel>
                    <div style="height: 5px">
                        &nbsp;
                    </div>
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender2" runat="server" Collapsed="true"
                                TargetControlID="PanelTimKiemNangCao2" CollapseControlID="PanelTimKiemNangCao1"
                                CollapsedImage="images/Expand.png" CollapsedText="(Mở ra)" ExpandControlID="PanelTimKiemNangCao1"
                                ExpandedImage="images/collape.png" ExpandedText="(Đóng lại)" ImageControlID="Image2"
                                TextLabelID="Label2">
                            </asp:CollapsiblePanelExtender>
                            <asp:Panel ID="PanelTimKiemNangCao2" runat="server">
                                <table style="border: thin solid #0066cc; border-collapse: collapse; width: 100%;
                                    background-color: white" align="center">
                                    <tr>
                                        <td style="width: 18%; text-align: right">
                                            Tên rao vặt
                                        </td>
                                        <td style="width: 1%">
                                            &nbsp;
                                        </td>
                                        <td style="width: 28%; text-align: left">
                                            <asp:TextBox ID="txtTenRaoVat" runat="server" BorderStyle="Solid" Width="165"></asp:TextBox>
                                        </td>
                                        <td style="width: 4%">
                                            &nbsp;
                                        </td>
                                        <td style="width: 18%; text-align: right">
                                            Nội dung rao vặt
                                        </td>
                                        <td style="width: 1%">
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:TextBox ID="txtNoiDungRaoVat" runat="server" BorderStyle="Solid" Width="165"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right">
                                            Danh mục
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:DropDownList ID="ddlDanhMuc" runat="server" Width="168px">
                                            </asp:DropDownList>
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: right">
                                            Địa điểm
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:DropDownList ID="ddlDiaDiem" runat="server" Width="168px">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right">
                                            Giá từ
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:TextBox ID="txtGiaTu" runat="server" BorderStyle="Solid" Width="165"></asp:TextBox>
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: right">
                                            Giá đến
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:TextBox ID="txtGiaDen" runat="server" BorderStyle="Solid" Width="165"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right">
                                            Ngày đăng từ
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:DropDownList ID="ddlNgayTu" runat="server" Width="40px">
                                            </asp:DropDownList>
                                            /
                                            <asp:DropDownList ID="ddlThangTu" runat="server" Width="40px">
                                            </asp:DropDownList>
                                            /
                                            <asp:DropDownList ID="ddlNamTu" runat="server" Width="57px">
                                            </asp:DropDownList>                                            
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: right">
                                            Ngày đăng đến
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left">
                                            <asp:DropDownList ID="ddlNgayDen" runat="server" Width="40px">
                                            </asp:DropDownList>
                                            /
                                            <asp:DropDownList ID="ddlThangDen" runat="server" Width="40px">
                                            </asp:DropDownList>
                                            /
                                            <asp:DropDownList ID="ddlNamDen" runat="server" Width="57px">
                                            </asp:DropDownList> 
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="7">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="7" align="center">
                                            <asp:Button ID="btnSearch2" runat="server" Text="Tìm kiếm" OnClick="btnSearch2_Click" />
                                        </td>
                                    </tr>
                                    <% if (ListMessage.Count > 0)
                                       {                            
                                    %>
                                    <tr>
                                        <td colspan="7">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <% for (int i = 0; i < ListMessage.Count; ++i)
                                       {                             
                                    %>
                                    <tr>
                                        <td colspan="7" align="center">
                                            <div style="color: Red; font-size: smaller">
                                                <%= ListMessage[i]%>
                                            </div>
                                        </td>
                                    </tr>
                                    <% } %>
                                    <tr>
                                        <td colspan="7">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <% } %>
                                </table>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                <p>
                    &nbsp;
                </p>
            </div>
            <div style="background-color: White">
                <p style="text-align: center; font-size: larger; color: Blue">
                    KẾT QUẢ</p>
                <br />
                <% if (DSCapDanhMucCon.Count <= 0)
                   {        
                %>
                <p style="text-align: center; font-size: larger; color: Red">
                    Không tìm thấy</p>
                <% }
                   else
                   {
                %>
                <p style="text-align: center; font-size: large">Tìm được <a><%= DS.Count %></a> bài viết</p>
                <br />  
                <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <%                
                        for (int k = 0; k < DSCapDanhMucCon.Count; )
                        {                            
                    %>
                    <tr>
                        <%
                            for (int z = k; z < k + 3 && z < DSCapDanhMucCon.Count; ++z)
                            {                           
                        %>
                        <td style="text-align: center; width: 33%">
                            <a href="TimKiem.aspx?MaTimKiem=<%= DSCapDanhMucCon[z].MaDanhMuc %>">
                                <%= DSCapDanhMucCon[z].TenDanhMuc + " (" + DSCapDanhMucCon[z].SoLuong.ToString() + ")"%>
                            </a>
                            <div style="height: 8px">&nbsp;</div>
                        </td>
                        <% }
                            k += 3;
                        %>
                    </tr>
                    <% } %>
                </table>
                <br />
                <% } %>
                <% if (DSTinRaoVatTheoMuc.Count > 0)
                   {                                       
                %>
                <br />
                <p style="text-align: center; font-size: larger; color: Red">
                    <%= TenDanhMucConHienHanh %>
                </p>
                <br />
                <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" DataKeyField="MaTinRaoVat"
                    RepeatColumns="1" Width="100%">
                    <ItemTemplate>
                        <table border="0" cellspacing="0" cellpadding="0" align="center">
                            <tr>
                                <td style="vertical-align: top">
                                    <asp:Image ID="Image1" runat="server" Height="100px" Width="100px" ImageUrl='<%# Eval("Thumbnail", "~/{0}") %>' />
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td valign="top" style="width: 100%; background-color: Silver">
                                    <asp:HyperLink ID="HyperLink1" runat="server" Style="color: #0034b8; font-size: medium"
                                        NavigateUrl='<%# Eval("MaTinRaoVat", "~/ChiTietTinRao.aspx?MaTin={0}") %>' Text='<%# Eval("TenTinRaoVat") %>'>
                                    </asp:HyperLink>
                                    <br />
                                    <br />
                                    <a style="font-size: small">&nbsp;&nbsp;&nbsp;* Giá: <asp:Label ID="GiaTienLabel" runat="server" Text='<%# Eval("GiaTien", "{0} VNĐ") %>'
                                        Style="color: Red; font-size: small" /></a>
                                    <br />
                                    <a style="font-size: small">&nbsp;&nbsp;&nbsp;* Ngày đăng: <asp:Label ID="NgayDangLabel" runat="server" Text='<%# Eval("ThoiGianDang") %>'
                                        Style="color: Red; font-size: small" /></a>
                                    <br />                                                                    
                                    <p style="text-align: right; color: Maroon">
                                        <asp:HyperLink ID="HyperLink2" runat="server" Style="color: #0034b8; font-size: large"
                                        NavigateUrl='<%# Eval("MaTinRaoVat", "~/ChiTietTinRao.aspx?MaTin={0}") %>' Text="Chi tiết" ForeColor="Maroon" BackColor="#FFFF66">
                                    </asp:HyperLink>
                                    </p>                                    
                                </td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:DataList>
                <br />
                <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
                    <tr>
                        <td align="right">
                            <asp:LinkButton ID="lbtnFirst" runat="server" CausesValidation="false" OnClick="lbtnFirst_Click">Trang 
                    đầu</asp:LinkButton>
                            &nbsp;
                            <asp:LinkButton ID="lbtnPrevious" runat="server" CausesValidation="false" OnClick="lbtnPrevious_Click">Trang 
                    trước</asp:LinkButton>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td align="center">
                            <asp:DataList ID="dlPaging" runat="server" RepeatDirection="Horizontal" OnItemCommand="dlPaging_ItemCommand"
                                OnItemDataBound="dlPaging_ItemDataBound">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkbtnPaging" runat="server" CommandArgument='<%# Eval("PageIndex") %>'
                                        CommandName="Paging" Text='<%# Eval("PageText") %>'></asp:LinkButton>&nbsp;
                                </ItemTemplate>
                            </asp:DataList>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td align="left">
                            <asp:LinkButton ID="lbtnNext" runat="server" CausesValidation="false" OnClick="lbtnNext_Click">Trang 
                    tiếp</asp:LinkButton>
                            &nbsp;
                            <asp:LinkButton ID="lbtnLast" runat="server" CausesValidation="false" OnClick="lbtnLast_Click">Trang 
                    cuối</asp:LinkButton>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="5" align="center" style="height: 30px" valign="middle">
                            <asp:Label ID="lblPageInfo" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
                <% } %>
            </div>
        </div>
    </div>
</asp:Content>
